from iClouds.apiSerializers import *
from iClouds.apiExceptions import *
from iClouds.apiheader import *


class TankUsernameListSerializer(serializers.ModelSerializer):
    id = IntegerField(label="ID", read_only=True)
    username = CharField(
        allow_blank=True,
        allow_null=True,
        max_length=255,
        validators=[UniqueValidator(queryset=TankUsernameList.objects.all())],
        help_text="用户名",
    )
    password = CharField(
        allow_blank=True, allow_null=True, max_length=255, help_text="密码(密文)"
    )
    phone = CharField(
        allow_blank=True,
        allow_null=True,
        max_length=255,
        required=False,
        validators=[UniqueValidator(queryset=TankUsernameList.objects.all())],
        help_text="电话",
    )
    email = CharField(
        allow_blank=True,
        allow_null=True,
        max_length=255,
        required=False,
        validators=[UniqueValidator(queryset=TankUsernameList.objects.all())],
        help_text="邮箱",
    )
    current = DateTimeField(read_only=True, help_text="创建时间")
    lasttime = DateTimeField(read_only=True, help_text="上次登录")
    status = IntegerField(read_only=True, help_text="账户状态")
    is_authenticated = IntegerField(read_only=True, help_text="账户认证")

    class Meta:
        model = TankUsernameList
        fields = "__all__"


# print(repr(TankUsernameListSerializer()))
